#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/11/8 17:52
@desc
"""
import time
import datetime

t = time.time()

print (t)  # 原始时间数据   1541671033.02
print (int(t))  # 秒级时间戳  1541671033
print (int(round(t * 1000)))  # 毫秒级时间戳  1541671033024

nowTime = lambda: int(round(t * 1000))
print (nowTime())  # 毫秒级时间戳，基于lambda
print('f:' , datetime.datetime.now())
print (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))  # 日期格式化
print (datetime.datetime.now().strftime('%a, %Y-%b-%d %H:%M:%S %Z'))  # 日期格式化

print(datetime.date.today())     # 2018-11-08
print(datetime.datetime.now())   # 2018-11-08 17:54:24.169000


nowTime1 = lambda: str(int(round(t * 1000)))
# print(nowTime())
print(nowTime()/1000)
# 时间戳转换为指定格式的日期
# 使用time
timeStamp = 1543386246
print(timeStamp)
timeArray = time.localtime(timeStamp)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(otherStyleTime)   # 2013--10--10 23:40:00


nt = nowTime()/1000
subt = nt - timeStamp
print(subt)


today=time.strftime("%Y-%m-%d", time.localtime(nowTime()/1000))
print('today:' + today)
